<?php 
include '../library/config.php';
include '../library/connect.php';
//This is the directory where images will be saved 
$target = "../movieimg/"; 
$target = $target . basename( $_FILES['uploaded']['name']); 

//This gets all the other information from the form 
$movieID=$_POST['movieID']; 
$title=$_POST['title']; 
$description=$_POST['description']; 
$director=$_POST['director']; 
$day=$_POST['day']; 
$month=$_POST['month'];
$year=$_POST['year'];  
$movieflv=$_POST['movieflv']; 
$pic=($_FILES['uploaded']['name']); 

//create the date in right format
$releasedate = $year . "-" . $month . "-" . $day;

//Writes the information to the database 
mysql_query("INSERT INTO `p1_Movies` VALUES ('$movieID', '$title', '$pic', '$movieflv', '$description', '$director', '$releasedate')") ; 

//Writes the photo to the server 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{ 

//Tells you if its all ok 
$result = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; 
} 
else { 

//Gives and error if its not 
$result =  "Sorry, there was a problem uploading your file. Please retry"; 
} 
include '../library/disconnect.php';
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="admin.css" type="text/css" />
<title>Add Movie</title>
</head>
<body>
<p><?php echo $result; ?></p>
<a href="newmovie.php">Go Back</a>
</body>
</html>